package com.yoso.shop.infrastructure.rabbitmq;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Service;

/**
 * @author shizejin
 */
@Slf4j
@Service
@EnableBinding(Sink.class)
public class MessageProducer {
    @Autowired
    private Sink sink;

    public void publish(String message) {
        log.info("MQ消息入参:{}", message);
        sink.output().send(MessageBuilder.withPayload(message).build());
    }
}
